package com.caijb.redisdemo.controller;

import com.caijb.redisdemo.dto.Person;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;

/**
 * @author caijb
 * @version 1.0
 * @data 2025/11/8 01:02
 */

@RestController
public class ReactiveController {

    @PostMapping("/testFlux")
    public Mono<String> test(@RequestBody Person person) {
        System.out.println(Thread.currentThread().getName());
        return Mono
                .just(person)
                .subscribeOn(Schedulers.boundedElastic())
                .map(p -> {
                    System.out.println(Thread.currentThread().getName());
                    return "hello " + p.getName();
                });
    }
}
